home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / WinGnuPlot22.lha / WinGnuPlot / Source / WinPlot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-11  |  3.1 KB  |  146 lines

  1. #include "struct.c"
  2. #include "WinPlot.h"
  3. #include "amigawin.h"
  4.  
  5. /* at least Kick20 is required */
  6. long __oslibversion = 36;
  7. void __regargs __autoopenfail(char *);
  8.  
  9. /* the library bases */
  10. struct Library       *MUIMasterBase = NULL;
  11. struct FileRequester *FileReq = NULL;
  12.  
  13. /* some private definitions */
  14. static struct MsgPort *GnuPort = NULL;
  15.  
  16. int _STI_200_OpenMUI(void)
  17. {
  18.  
  19.  if (!(MUIMasterBase = OpenLibrary("muimaster.library", MUIMASTER_VMIN)))
  20.   {
  21.    __oslibversion = MUIMASTER_VMIN;
  22.    __autoopenfail("mui.library V2.1");
  23.    __oslibversion = 36;
  24.    return 1;
  25.   }
  26.  return 0;
  27. }
  28.  
  29. void _STD_200_CloseMUI(void)
  30. {
  31.  if (MUIMasterBase)
  32.   CloseLibrary(MUIMasterBase);
  33. }
  34.  
  35. int _STI_OpenSystem(void)
  36. {
  37.  char Buffer[255];
  38.  int  i;
  39.  
  40.  for(i=0; i<MAXWINDOW; i++)
  41.   Windows[i].WI_Plot = Windows[i].BT_Plot = Windows[i].BT_Load = Windows[i].BT_Save =
  42.   Windows[i].BT_CD = Windows[i].BT_Set = Windows[i].BT_New = Windows[i].BO_Plot = NULL;
  43.  GetCurrentDirName(Buffer, 255);
  44.  if (!(FileReq = MUI_AllocAslRequestTags(ASL_FileRequest,
  45.                      ASLFR_PrivateIDCMP,  TRUE,
  46.                      ASLFR_RejectIcons,   TRUE,
  47.                      ASLFR_InitialDrawer, Buffer,
  48.                      TAG_END)))
  49.   {
  50.    MUI_Request(NULL, NULL, 0, "WinPlot", "Ok", "CanĀ“t allocate FileRequest structure!\n");
  51.    return 1;
  52.   }
  53.  
  54. #ifndef _DEBUG
  55.  if (!FindPort(GNUREPLY))
  56.   {
  57.    MUI_Request(NULL, NULL, 0, "WinPlot", "Ok",
  58.            "This is a GnuPlot terminal driver, Please start GnuPlot first !");
  59.    return 1;
  60.   }
  61. #endif
  62.  
  63.  return 0;
  64. }
  65.  
  66. void _STD_CloseSystem(void)
  67. {
  68.  if (FileReq) MUI_FreeAslRequest(FileReq);
  69. }
  70.  
  71. ULONG main(void)
  72. {
  73.  BOOL                Quit = FALSE;
  74.  ULONG               PortFlag, RexxReplyFlag;
  75.  struct PlotMessage *PlotMsg;
  76.  struct Message     *Msg;
  77.  
  78.  if (GnuPort = CreatePort(GNUPORT, 0))
  79.   {
  80.    PortFlag = 1 << GnuPort->mp_SigBit;
  81.    RexxReplyFlag = 1 << RexxReplyPort->mp_SigBit;
  82.  
  83.    if (AP_WinPlot = GetGUI())
  84.    {
  85.     set(Windows[0].WI_Plot, MUIA_Window_Open, TRUE);
  86.     
  87.     while (!Quit)
  88.      {
  89.       LONG  MUI_ID;
  90.       ULONG MUI_Signal, Sig;
  91.       
  92.       MUI_ID = DoMethod(AP_WinPlot, MUIM_Application_Input, &MUI_Signal);
  93.       if (MUI_ID != 0)
  94.        Quit = HandleMUI(MUI_ID);
  95.       if (MUI_Signal)
  96.        Sig = Wait(MUI_Signal|PortFlag|RexxReplyFlag);
  97.       else
  98.        Sig = 0L;
  99.       
  100.       if (Sig & PortFlag)
  101.        while (PlotMsg = (struct PlotMessage *)GetMsg(GnuPort))
  102.     {
  103.      switch(PlotMsg->PlotCom.gpc_com)
  104.       {
  105.       case SET_GRAPHICS:
  106.        set(AP_WinPlot, MUIA_Application_Sleep, TRUE);
  107.        break;
  108.       case SET_TEXT:
  109.        ncommands = PlotMsg->PlotCom.gpc_ncommands;
  110.        commands = PlotMsg->PlotCom.gpc_commands;
  111.        set(AP_WinPlot, MUIA_Application_Sleep, FALSE);
  112.        Refresh();
  113.        break;
  114.       case RESET:
  115.        Quit = TRUE;
  116.        break;
  117.       case SETVAR:
  118.        Settings((struct SetVar *)PlotMsg->PlotCom.gpc_arg);
  119.        break;
  120.       case PAUSE:
  121.        WaitRequest(PlotMsg->PlotCom.gpc_arg);
  122.        break;
  123.       }
  124.     
  125.      ReplyMsg(PlotMsg);
  126.     }
  127.       if (Sig & RexxReplyFlag)
  128.        if (GetMsg(RexxReplyPort))
  129.     ReplyRexxMsg();
  130.      }
  131.  
  132.     while (Msg = GetMsg(GnuPort))
  133.      ReplyMsg(Msg);
  134.     while (Msg = GetMsg(RexxReplyPort))
  135.      ReplyMsg(Msg);
  136.  
  137.     SaveConf();
  138.     MUI_DisposeObject(AP_WinPlot);
  139.  
  140.    }
  141.    DeletePort(GnuPort);
  142.   }
  143.  
  144.  return 0;
  145. }
  146.